// index.js
var app=getApp();
var img_src=app.globalData.img_src;
var img_link="cloud://prod-4gezc6h712244ed8.7072-prod-4gezc6h712244ed8-1314008217/assets/public/"
Page({
  data:{ 
    hsbgp_src:img_src+"hsbgp.png",
    scroll_view_s:[
      img_src+"box1.png",
      img_src+"box2.png",
      img_src+"box3.png",
      img_src+"box1.png",
      img_src+"box2.png",
      img_src+"box3.png"],
    scroll_view_l:[
      img_src+"lbox1.png",
      img_src+"lbox2.png",
      img_src+"lbox3.png",
      img_src+"lbox1.png",
      img_src+"lbox2.png",
      img_src+"lbox3.png"],
      show_place:false,
      img_link:img_link
  },
  onLoad:function(){
    var that=this
    console.log("link",this.data.img_link)
    // set top distance
    let menuButtonObject = wx.getMenuButtonBoundingClientRect();

    wx.getSystemInfo({
      success: res => {
        let statusBarHeight = res.statusBarHeight,
          navTop = menuButtonObject.top, //胶囊按钮与顶部的距离
          navHeight = statusBarHeight + menuButtonObject.height + (menuButtonObject.top - statusBarHeight) * 2; //导航高度
          this.setData({
            navTop:navTop,
            navHeight:navHeight,
          },()=>{
          })
      },
    })
    wx.cloud.callContainer({
      config: {
        env: 'prod-4gezc6h712244ed8', // 微信云托管的环境ID
      },
      path: '/api/master', // 填入业务自定义路径和参数，根目录，就是 / 
      method: 'GET', // 按照自己的业务开发，选择对应的方法
      header: {
        'X-WX-SERVICE': 'blackstone', // xxx中填入服务名称（微信云托管 - 服务管理 - 服务列表 - 服务名称）
      },
      success(res){
        let master_map={};
        for(let m of res.data){
          master_map[m.name]=m.id
        }
        that.setData({
          master_info:res.data
        })
        console.log("教练信息已返回",res.data)
        // console.log("???",master_map)
      }
    })
  },

  //  onReady: function () {
  //   this.setData({
  //     master_info:app.globalData.master_info,
  //     hh:app.globalData.hh
  //   })
  //   console.log("master",this.data.master_info,app.globalData.master_info)
    
  // },
  show_place_f(){
    let that=this
    this.setData({
      show_place:!that.data.show_place
    })
    setTimeout(()=>{
      if(that.data.show_place==true){
        this.setData({
          show_place:!that.data.show_place
        })
      }
    },3000)
  },
  onShareAppMessage: function () {
    return {
      title: '黑石拳击',
      path: '/pages/index/index'
    }
  },
  onShareTimeline(){
    return {
      title: '黑石拳击',
      path: '/pages/index/index'
    }
  }

})
